package com.yckj.dao;

import com.yckj.domain.Lawyer;
import org.junit.Test;

import java.util.Scanner;

import static org.junit.Assert.*;

public class UserDaoTest extends Lawyer {
    //
    UserDao userDao = new UserDao();
    @Test
    public void insertUser() {
        int flag = userDao.insertUser("xueben","123456");
        if(flag == 1){
            System.out.println("注册成功！");
        }else{
            System.out.println("注册失败");
        }
    }

    @Test
    public void login() {
        //Java语言接收键盘输入的数据用Scanner
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入用户名: ");
        //接受键盘上输入的用户名
        String uname = scanner.next();

        System.out.println("请输入密码: ");
        String upsw = scanner.next();

        boolean flag = userDao.login(uname,upsw);
        if(flag == true){
            System.out.println("登陆成功！欢迎" + uname);
        }else {
            System.out.println("用户名或密码错误！");
        }
    }

    @Test
    public void deleteUser() {
        int flag = userDao.deleteUser(1);
        System.out.println(flag);
    }

    @Test
    public void updateUser() {
        int flag = userDao.updateUser(2,"wangxiao","123jie");
        System.out.println(flag);
    }

    @Test
    public void selectAllUsers() {
        System.out.println(userDao.selectAllUsers());
    }
}